package com.chuyangc.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;

/**
 * @author 欧楚杨
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docketGoods() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("商品组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/goods/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    @Bean
    public Docket docketSellers() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("商家组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/sellers/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("欧楚杨", "", "chu_yang1025@163.com");
        return new ApiInfo("JavaEE期中考核作业接口文档",
                "Swagger生成接口文档",
                "1.0",
                "",
                contact.getName(),
                "Apache 2.0",
                "");
    }
}

